/*                                                             
ID: wxm071
PROG: beads
LANG: C++14
*/
#include <string>
#include <vector>
#include <fstream>
#include <iostream>

using namespace std;

int rcountbeads(int cut, const string &str){
    int num = 0;
    int j = cut;

    for(int i = 0; i < str.size(); ++i){
        if(j == str.size()){
            j = 0;
        }

        if(str[cut] == 'w'){
            ++cut;
        }
        else{
            if(str[cut] != str[j] && str[j] != 'w'){
                break;
            }
        }   

        ++num;
        ++j;
    }

    return num;
}

int lcountbeads(int cut, const string &str){
    int num = 0;
    int j = cut;

    for(int i = 0; i < str.size(); ++i){
        if(j == -1){
            j = str.size() - 1;
        }
        
        if(str[cut] == 'w'){
            --cut;
        }
        else{
            if(str[cut] != str[j] && str[j] != 'w'){
                break;
            }
        } 
        ++num;
        --j;
    }

    return num;
}

int collectbeads(string str){
    int maxnum = 0;
    int rnum, lnum;

    for(int cut = 0; cut < str.size(); ++cut){
        rnum = rcountbeads(cut, str);
        if(rnum < str.size())
            lnum = lcountbeads(cut-1, str);
        else
            lnum = 0;
            
        maxnum = max(rnum+lnum, maxnum);
    }
    return maxnum;
}

int main(int argc, char const *argv[])
{
    ifstream ifs("beads.in");

    int n = 0;
    string str;

    ifs>>n;
    ifs>>str;

    ofstream ofs("beads.out");

    ofs<<collectbeads(str)<<endl;

    return 0;
}